﻿using System;
using AutoMapper;
using Blog.Domain;
using Blog.UI.Models;

namespace Blog.UI.Infra.AutoMapper
{
    public class PostViewModelToPostProfile : Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<PostViewModel, Post>()
                .ForMember(c => c.Author, c => c.MapFrom(d => new Author { Name = d.Author }))
                .ForMember(c => c.Title, c => c.MapFrom(d => d.Title))
                .ForMember(c => c.CreatedAt, c => c.MapFrom(d => DateTime.Now))
                .ForMember(c => c.Body, c => c.MapFrom(d => d.Body))
                .ForMember(c => c.Slug, c => c.MapFrom(d => d.Slug));
        }
    }
}